package com.hutou.chuangke.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.hutou.chuangke.Bean.AlbnmlistBean;
import com.hutou.chuangke.Bean.MvlistBean;
import com.hutou.chuangke.Bean.SoundBean;
import com.hutou.chuangke.R;
import com.nostra13.universalimageloader.core.ImageLoader;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2017/5/5.
 */

public class ImageGridviewAdapter extends BaseAdapter {
    Context mContext;
    List<?> list = new ArrayList<>();

    public ImageGridviewAdapter(Context context, List<?> list) {
        this.mContext = context;
        this.list = list;

    }

    @Override
    public int getCount() {

        return list.size();

    }

    @Override
    public Object getItem(int position) {

        return list.get(position);


    }

    @Override
    public long getItemId(int position) {

        return position;

    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder;
        if (convertView == null) {
            LayoutInflater inflater = LayoutInflater.from(mContext);
            convertView = inflater.inflate(R.layout.item_gridview_image,parent,false);
//            convertView = View.inflate(mContext,
//                    R.layout.item_gridview_image, parent);
            holder = new ViewHolder();
            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }
        holder.imageview = (ImageView) convertView.findViewById(R.id.imageview);
        if (list.get(position) instanceof String) {
            ImageLoader.getInstance().displayImage((String) list.get(position), holder.imageview);
        }
        return convertView;
    }

    private class ViewHolder {
        ImageView imageview;
    }
}